package com.mrjy.maintain.bo;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.mrjy.common.dto.WeUIPickerDto;
import com.mrjy.maintain.dao.IGradeInfoDao;

@Service("gradeInfoBo")
public class GradeInfoBo implements IGradeInfoBo{

	@Resource
	private IGradeInfoDao gradeInfoDao;

	@Override
	public Object txInsert(Object object) {
		return gradeInfoDao.insert(object);
	}

	@Override
	public Object txDeleteByIds(int[] ids) {
		try {
			return gradeInfoDao.deleteByIds(ids);
		} catch (Exception e) {
			return 0;
		}
	}

	@Override
	public Object updateDisableFlag(Object object) {
		return gradeInfoDao.updateDisableFlag(object);
	}

	@Override
	public Object txUpdateById(Object object) {
		return gradeInfoDao.updateById(object);
	}

	@Override
	public Object queryById(int id) {
		return gradeInfoDao.queryById(id);
	}

	@Override
	public Object queryList(Object object) {
		return gradeInfoDao.queryList(object);
	}

	@Override
	public Object queryPage(Object object) {
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("total", gradeInfoDao.countList(object));
		map.put("rows", gradeInfoDao.queryList(object));
		return map;
	}

	@Override
	public Object queryListByUserMember(Integer userId) {
		// TODO Auto-generated method stub
		return gradeInfoDao.queryListByUserMember(userId);
	}

	@Override
	public Object queryListForWeUIPicker() {
		Map<String,Object> map = new HashMap<String, Object>();
		List<WeUIPickerDto> list = gradeInfoDao.queryListForWeUIPicker();
		if (null != list) {
			Map<String, Object> dicMap = new HashMap<String, Object>();
			for(WeUIPickerDto dto : list){
				dicMap.put(dto.getValue(), dto.getLabel());
			}
			map.put("err_code", 0);
			map.put("err_msg", "查询成功");
			map.put("gradeInfoList", list);
			map.put("dicMap", dicMap);
		}else {
			map.put("err_code", 1);
			map.put("err_msg", "没有数据");
		}
		return map;
	}
	
}
